package main

import "fmt"

type Person struct {
	name, city string
	age        int
	school     struct {
		name, city string
		age        int
	}
}

// 结构体构造函数,只返回构造结构体的指针地址，减少内存开销
func newPerson(city, name string, age int) *Person {
	return &Person{
		city: city,
		name: name,
		age:  age,
	}
}

func main() {
	// 不赋值的 key 会取该类型的零值
	_ = Person{name: string("000"), age: 22, school: struct {
		name, city string
		age        int
	}{name: "name", city: "city", age: 10}}

	// 初始化一个指针类型
	p2 := &Person{name: "string"}

	p3 := Person{"name", "city", 11, struct {
		name, city string
		age        int
	}{"name", "city", 22}}

	// 创建指针类型的结构体 通过new
	//p_pointer := new(Person)
	//fmt.Printf("%T", p_pointer)
	//(*p_pointer).name = "name"
	//p_pointer.age = 10

	//	取结构体地址进行实例化
	p4 := &Person{}
	fmt.Println(p4)

	p5 := p4 // 值拷贝

}
